package com.zzf.concurrent.example.design.pattern.active.object.client;

import com.zzf.concurrent.example.design.pattern.active.object.ActiveObject;
import com.zzf.concurrent.example.design.pattern.active.object.Result;
import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/9/11 15:10
 */
@Slf4j
public class MarkStringClientThread extends Thread {

    private volatile int count;
    private final char ch;
    private ActiveObject activeObject;

    public MarkStringClientThread(ActiveObject activeObject, int count, char ch) {
        this.count = count;
        this.ch = ch;
        this.activeObject = activeObject;
    }

    @Override
    public void run() {
        while (true) {
            Result result = activeObject.makeString(count++, ch);
            log.info("mark string result -> {}", result.getResultValue());
        }
    }

}
